/*
 *  
    Copyright (C) 2008  Nathaniel Waisbrot

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package termint.gui;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;

import termint.gui.vt.VT320;
import termint.gui.vt.VTElement;

/**
 * SWTTerm is a subclass of {@link Canvas} which draws the main dungeon map.
 * SWTTerm is an abstract base class.
 * @author Nathaniel Waisbrot
 *
 */
public abstract class SWTTerm extends Canvas implements PaintListener {
	protected VT320 vt;
	protected final static int rows = 24;
	protected final static int cols = 80;
	protected final static int topMargin = 10;
	protected final static int leftMargin = 10;

	public SWTTerm(Composite parent) {
		this(parent, new VT320(cols,rows));
	}
	
	public SWTTerm(Composite parent, VT320 vt) {
		super(parent, SWT.NO_REDRAW_RESIZE);
		this.vt = vt;
		this.addPaintListener(this);
	}
	
	public abstract void paintControl(PaintEvent arg0);

	public void addData(String s) {
		vt.putString(s);
	}
	
	public abstract VTElement tileAtPoint(Point p);
	public VTElement tileAtPoint(int x, int y) { return tileAtPoint(new Point(x, y)); }
}
